package com.thenie.service.impl;

import com.thenie.mapper.RoomTypeMapper;
import com.thenie.pojo.RoomType;
import com.thenie.service.RoomTypeService;
import com.thenie.vo.RoomTypeVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class RoomTypeServiceImpl implements RoomTypeService {

    @Resource
    private RoomTypeMapper roomTypeMapper;

    /**
     * 查询房型列表
     * @param roomTypeVo
     * @return
     */
    public List<RoomType> findRoomTypeList(RoomTypeVo roomTypeVo){
        return roomTypeMapper.findRoomTypeList(roomTypeVo);
    }
    /**
     * 添加一条房型
     * @param roomType
     * @return
     */
    public int addRoomType(RoomType roomType){
        roomType.setAvailableNum(roomType.getRoomNum());//可入住数量
        roomType.setReservedNum(0);//已预订数量
        roomType.setLivedNum(0);//已入住数量
        return roomTypeMapper.insertRoomType(roomType);
    }
    /**
     * 修改房型信息
     * @param roomType
     * @return
     */
    public int updateRoomType(RoomType roomType){
        return roomTypeMapper.updateRoomType(roomType);
    }

    /**
     * 查询一条房型
     * @param id
     * @return
     */
    public RoomType selectRoomTypeById(int id){
        return roomTypeMapper.selectRoomTypeById(id);
    }
}
